﻿""" pyTorreador - simply web client for rTorrent """
__version__ = "0.0.1"
__license__ = "GNU General Public License v2"
__author__ = "nick voronin <nickvor@gmail.com>"

import web

def checkauth(session):
    if session.logged == 1:
        return True
    return False

def checkaccess(auth = False, session = False):
    def decorator(func):
        def proxyfunc(self, *args, **kw):
            if auth == True:
                if not session:
                    return web.redirect('/login')
                else:
                    if not checkauth(session):
                        return web.redirect('/login')
            return func(self, *args, **kw)
        return proxyfunc
    return decorator
